﻿@using Newtonsoft.Json
@using Pyramid.Models
@using Pyramid.Mvc.Html
@model CustomerHealthArchiveMaster

<div class="pageContent">
	<div class="pageFormContent" layouth="62">
		<p>
			@Html.LabelFor(model => model.CustomerCode)
			@Html.ReadonlyFieldFor(model => model.CustomerCode)
		</p>
		<p>
			@Html.LabelFor(model => model.CustomerFullName)
			@Html.ReadonlyFieldFor(model => model.CustomerFullName)
		</p>
		<p>
			@Html.LabelFor(model => model.Height)
			@Html.ReadonlyFieldFor(model => model.Height)
		</p>
		<p>
			@Html.LabelFor(model => model.Weight)
			@Html.ReadonlyFieldFor(model => model.Weight)
		</p>
		<p>
			@Html.LabelFor(model => model.BodilyForm)
			@Html.TextBox("BodilyForm", Model.BodilyFormString, new {@readonly = "readonly"})
		</p>
		<p class="nowrap">
			@Html.LabelFor(model => model.Hypersusceptibility)
			@Html.TextAreaFor(model => model.Hypersusceptibility, new {@class = "longText longParagraph"})
		</p>
		<p class="nowrap">
			@Html.LabelFor(model => model.Disease)
			@Html.TextAreaFor(model => model.Disease, new {@class = "longText longParagraph"})
		</p>
		<p class="nowrap">
			@Html.LabelFor(model => model.Operation)
			@Html.TextAreaFor(model => model.Operation, new {@class = "longText longParagraph"})
		</p>
		<p class="nowrap">
			@Html.LabelFor(model => model.Heredopathia)
			@Html.TextAreaFor(model => model.Heredopathia, new {@class = "longText longParagraph"})
		</p>
		<p class="nowrap">
			@Html.LabelFor(model => model.HumanBodySystem)
			<div>
				@{
					var systems = (IEnumerable<HumanBodySystem>) ViewBag.HumanBodySystemOptions;
					var selectedItems = new List<int>();
					if (!string.IsNullOrWhiteSpace(Model.HumanBodySystem))
					{
						selectedItems = JsonConvert.DeserializeObject<List<int>>(Model.HumanBodySystem);
					}
					<table>
						@foreach (var sys in systems)
						{
							<tr>
								<td width="120">@sys.Name</td>
								<td>
									@foreach (var condition in sys.HealthConditions)
									{
										<label>
											<input type="checkbox" name="selectedConditions" value="@condition.Id" 
												@(Html.Raw((selectedItems.Count > 0 && selectedItems.Contains(condition.Id)) ? "checked=\"checked\"" : "")) />
											@condition.Name
										</label>
									}
								</td>
							</tr>
						}
					</table>
				}
			</div>
		</p>
	</div>
</div>